const char *loop_event_script = 
"import * as std from 'std';\n"
"import * as os from 'os';\n"
"globalThis.std = std;\n"
"globalThis.os = os;\n"
"globalThis._string_includes = (str, search) => {"
"  return str.includes(search);"
"};"
"globalThis._string_replace = (str, search, replace) => {"
"  return str.replace(search, replace);"
"};"
"\n"
"const timeTaskList = [];\n"
"let timerId = 0;\n"
"globalThis.setTimeout = (fn, delay, ...args) => {\n"
"    timerId++;\n"
"    const time = new Date().getTime() + (delay || 0);\n"
"    timeTaskList.push({ fn, time, id: timerId, args, cleaned: false })\n"
"    return timerId\n"
"}\n"
"globalThis.clearTimeout = (id) => {\n"
"    for (const i of timeTaskList) {\n"
"        if (i.id == id) {\n"
"            i.cleaned = true;\n"
"            break;\n"
"        }\n"
"    }\n"
"}\n"
"\n"
"\n"
"const loopTaskList = []\n"
"globalThis.setInterval = (fn, time, ...args) => {\n"
"    timerId++;\n"
"    loopTaskList.push({ fn, args, id: timerId, delay: time, runtime: new Date().getTime() + (time || 0), cleaned: false })\n"
"    return timerId\n"
"}\n"
"globalThis.clearInterval = (id) => {\n"
"    for (const i of loopTaskList) {\n"
"        if (i.id == id) {\n"
"            i.cleaned = true;\n"
"            break;\n"
"        }\n"
"    }\n"
"}\n"
"\n"
"\n"
"let frame = 0;\n"
"globalThis.__gameFrameCallback = () => {\n"
"    frame++;\n"
"    const time = new Date().getTime();\n"
"    const doedTask = []\n"
"    for (const i of timeTaskList) {\n"
"        if (i.time <= time) {\n"
"            doedTask.push(i);\n"
"            if (i.cleaned) continue;\n"
"            try {\n"
"                i.fn.apply(undefined, i.args)\n"
"            } catch (error) {\n"
"                console.log(error, \"Timeouter Error\")\n"
"            }\n"
"        }\n"
"    }\n"
"\n"
"    for (const i of doedTask) {\n"
"        timeTaskList.splice(timeTaskList.indexOf(i), 1)\n"
"    }\n"
"\n"
"\n"
"    const needclean = []\n"
"    for (const i of loopTaskList) {\n"
"        if (i.runtime <= time) {\n"
"            if (i.cleaned) {\n"
"                needclean.push(i);\n"
"                continue;\n"
"            }\n"
"            i.runtime = time + i.delay\n"
"            try {\n"
"                i.fn.apply(undefined, i.args)\n"
"            } catch (error) {\n"
"                console.log(error, \"Intervaler Error\")\n"
"            }\n"
"        }\n"
"    }\n"
"    for (const i of needclean) {\n"
"        loopTaskList.splice(loopTaskList.indexOf(i), 1)\n"
"    }\n"
"    return frame;\n"
"}\n";